package simple1;

import java.io.*;
import java.util.*;

import org.apache.log4j.*;

/**
 * 簡單的 Log4j 的測試<br>
 * 在 Simple1Log4j.properties 有完整的指令介紹<br>
 * 使用 RootLogger<br>
 * 
 * Copyright: Copyright (c) 2002-2007<br>
 * Company: E885 工作室<br>
 * 
 * @author Eric Gau E-mail: gau168.gau@msa.hinet.net
 * @version 1.0
 */
public class TestLog4jSimple1
{
    public TestLog4jSimple1()
        throws IOException
    {
    	//有指定讀取 log4j.properties 的路徑, 因為 log4j 的預設路徑是沒有 package
        Properties properties = new Properties();

        InputStream inputStream = TestLog4jSimple1.class.getClassLoader()
            .getResourceAsStream( "simple1/Simple1Log4j.properties" );

        properties.load( inputStream );

        PropertyConfigurator.configure( properties );
        //========================================================================

        Logger logger = Logger.getRootLogger();
        
        logger.debug( "Hello Log4j for debug" );
        logger.info( "Hello Log4j for info" );
        logger.warn( "Hello Log4j for warn" );
        logger.error( "Hello Log4j for error" );
        logger.fatal( "Hello Log4j for fatal" );
    }

    public static void main( String[] args )
    {
        try
        {
            new TestLog4jSimple1();
        }
        catch( IOException ex )
        {
            ex.printStackTrace();
        }
    }
}
